//不要在析构函数中主动抛出异常
#include <iostream>
using namespace std;

void foo() {
	throw "foo函数中抛出的异常";
}
void bar() {
	throw "foo函数中抛出的异常";
}
class A {
public:
	~A() {
	//	throw "析构函数中抛出的异常";
		try {
			bar();
		}
		catch (const char* e) {
			cout << "析构函数中捕获异常信息:" << e << endl;
		}
	}
};

int main(void) {
	try {
		A a;
		foo();
		//...其它代码
	}//a.~A()
	catch(const char* e){
		cout << "main函数中捕获的异常信息" << e << endl;
	}

	return 0;
}